new Vue({
    el: "#mainContent",
    data: {
        cardList: [],
        listCardUrl: "/card/get_card_list.ajax",
        deleteCardUrl: "/card/delete_card.ajax"
    },
    mounted: function () {
        this.initPage();
    },
    methods: {
        initPage: function () {
            this.$http.get(this.listCardUrl)
                .then((response) => {
                    this.$set(this, "cardList", response.data.data);
                })
                .catch(function (response) {
                    console.log(response)
                });
        },
        deleteCard: function (event, card) {
            console.log(card.cardId);
            this.$http.post(this.deleteCardUrl, {cardId: card.cardId}, {emulateJSON: true})
                .then((response) => {
                    if (Number(response.data.code) == 0) {
                        alert("删除成功!");
                        location.reload();
                    } else {
                        alert("删除失败");
                    }
                })
                .catch(function (response) {
                    console.log(response)
                });
        }
    }
});